// rpx
const titleBarHeight = 88
const tabbarHeight = 115
const {
	windowHeight,
	screenWidth,
	screenHeight,
	statusBarHeight,
	windowBottom,
	safeArea,
	safeAreaInsets,
	pixelRatio,
} = uni.getWindowInfo()
// 像素比

/**
 * @description: 获取可用滚动区域高度
 * @param {number} topSafeAreaHeight 额外顶部安全区域高度
 * @param {number} bottomSafeAreaHeight 额外底部安全区域高度
 * @param {boolean} hasTitleBar 是否包含标题栏
 * @return {string}
 */
export function getSafeScrollHeight(
	topSafeAreaHeight = 0,
	bottomSafeAreaHeight = 0,
	hasTitleBar = true,
	hasTabber = false,
) {
	return `${screenHeight - statusBarHeight - safeAreaInsets?.bottom - (hasTitleBar ? rpx2px(titleBarHeight) : 0) - (hasTabber ? rpx2px(tabbarHeight) : 0) - rpx2px(topSafeAreaHeight) - rpx2px(bottomSafeAreaHeight)}px`
}

// 获取头部安全区域高度
export function getTopSafeAreaHeight(hasTitleBar = true) {
	return `${statusBarHeight + (hasTitleBar ? rpx2px(titleBarHeight) : 0)}px`
}

// 获取底部部安全区域高度
export function getBottomSafeAreaHeight() {
	return `${safeAreaInsets?.bottom}px`
}

function rpx2px(rpx) {
	return (rpx * screenWidth) / 750
}